import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yysk_app/pages/show_image/show_image_page.dart';
import 'package:yysk_app/routes/global_controller.dart';
import 'package:yysk_app/utils/colors.dart';
import 'package:yysk_app/utils/helper.dart';
import 'package:yysk_app/widget/custom_app_bar2.dart';
import 'package:yysk_app/widget/lazy_network_image.dart';

class SpokespersonPage extends StatefulWidget {
  static const path = '/SpokespersonPage';
  const SpokespersonPage({super.key});

  @override
  State<SpokespersonPage> createState() => _SpokespersonPage();
}

class _SpokespersonPage extends State<SpokespersonPage> {
  List<dynamic> lists = [];
  late String _type = '1';
  @override
  void initState() {
    super.initState();
    GlobalController globalController = Get.find();
    globalController.staticInfo();
  }

  @override
  Widget build(BuildContext context) {
    double top = MediaQuery.of(context).padding.top;
    GlobalController globalController = Get.find();
    final detail = globalController.staticInfo.value;
    return Scaffold(
      body: MediaQuery.removePadding(
        context: context,
        removeTop: true,
        child: Stack(
          children: [
            _type == '1'
                ? Positioned.fill(
                  child: LazyImage(
                    imageUrl: detail!.spokesmanIntro ?? '',
                    width: 375.px,
                    boxFit: BoxFit.cover,
                    aotuHeight: true,
                  ),
                  //  Image.asset('static/images/partner_bg1.png', fit: BoxFit.cover),
                )
                : Positioned.fill(
                  child: LazyImage(
                    imageUrl: detail!.copartnerIntro ?? '',
                    width: 375.px,
                    boxFit: BoxFit.cover,
                    aotuHeight: true,
                  ),
                ),
            Column(
              children: [
                Padding(
                  padding: EdgeInsets.only(top: top, bottom: 0.px),
                  child: CustomAppBar2(
                    title: '',
                    showChild: true,
                    context: context,
                    backgroundColor: AppColors.backgroundColor,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        GestureDetector(
                          onTap: () {
                            setState(() {
                              _type = "1";
                            });
                          },
                          child: Container(
                            width: 112.px,
                            height: 29.px,
                            decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(111.px),
                              color:
                                  _type == '1'
                                      ? Color.fromRGBO(81, 81, 81, 0.5)
                                      : Color.fromRGBO(81, 81, 81, 0),
                            ),
                            child: Center(
                              child: Text(
                                '品牌代言人',
                                style: TextStyle(
                                  color:
                                      _type == '1'
                                          ? AppColors.fontColor
                                          : Color.fromRGBO(81, 81, 81, 0.5),
                                  fontSize: 16.px,
                                  fontFamily: 'CustomFont',
                                ),
                              ),
                            ),
                          ),
                        ),
                        SizedBox(width: 20.px),
                        GestureDetector(
                          onTap: () {
                            setState(() {
                              _type = "2";
                            });
                          },
                          child: Container(
                            width: 112.px,
                            height: 29.px,
                            decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(111.px),
                              color:
                                  _type == '2'
                                      ? Color.fromRGBO(81, 81, 81, 0.5)
                                      : Color.fromRGBO(81, 81, 81, 0),
                            ),
                            child: Center(
                              child: Text(
                                '品牌合伙人',
                                style: TextStyle(
                                  color:
                                      _type == '2'
                                          ? AppColors.fontColor
                                          : Color.fromRGBO(81, 81, 81, 0.5),
                                  fontSize: 16.px,
                                  fontFamily: 'CustomFont',
                                ),
                              ),
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
                SizedBox(height: 50.px),
                Stack(
                  children: [
                    Container(
                        width: 375.px,
                        padding: EdgeInsets.only(left: 13.px, right: 13.px),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [],
                        ),
                      )
                  ],
                ),
              ],
            ),
            Positioned(
              left: 0,
              bottom: 43.px,
              child: GestureDetector(
                onTap: (){
  if (_type == '1') {
                          Get.toNamed(
                            '${ShowImagePage.path}?title=${'品牌代言人'}&url=${Uri.encodeComponent('${detail.spokesmanDetail}')}',
                            arguments: {
                              'title': '品牌代言人',
                              'url': Uri.encodeComponent(
                                '${detail.spokesmanDetail}',
                              ),
                            },
                          );
                        } else {
                          Get.toNamed(
                            '${ShowImagePage.path}?title=${'品牌合伙人'}&url=${Uri.encodeComponent('${detail.copartnerDetail}')}',
                            arguments: {
                              'title': '品牌合伙人',
                              'url': Uri.encodeComponent(
                                '${detail.copartnerDetail}',
                              ),
                            },
                          );
                        }
                },
                child:   SizedBox(
                width: 375.px,
                height: 26.px,
                child: Center(
                  child: Text(
                    '查看详情>',
                    style: TextStyle(
                      color: AppColors.fontColorGreenStart,
                      fontSize: 14.px,
                    ),
                  ),
                ),
              ),
              )
            ,
            ),
          ],
        ),
      ),
    );
  }
}
